package com.ts.content.controller;

import cn.hutool.core.lang.hash.Hash;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ts.common.core.constant.Constant;
import com.ts.common.core.utils.Result;
import com.ts.common.core.validator.AssertUtils;
import com.ts.common.core.validator.ValidatorUtils;
import com.ts.common.core.validator.group.AddGroup;
import com.ts.common.core.validator.group.DefaultGroup;
import com.ts.common.core.validator.group.UpdateGroup;
import com.ts.common.mybatis.page.PageData;
import com.ts.content.dto.CategoryDTO;
import com.ts.content.entity.CategoryEntity;
import com.ts.content.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 类目
 *
 * @author toString toString@qq.com
 * @since 1.0.0 2023-02-21
 */
@RestController
@RequestMapping("/category")
@Api(tags = "类目")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @PostMapping("list")
    public Page<CategoryEntity> list(@RequestBody Page<CategoryEntity> page) {
        return categoryService.page(page);
    }

    @PostMapping
    public Result save(@RequestBody CategoryEntity entity) {
        categoryService.save(entity);
        return new Result();
    }

    @GetMapping("/viewList")
    public Result viewList() {
        return new Result().ok(categoryService.list());
    }
}